<template>
    <div>
        <button @click="sendRequest">发送请求</button>
    </div>
</template>

<script>
import axios from 'axios'
export default {
    methods:{
        sendRequest(){
            if(this.cancel!=null){
                this.cancel()//取消之前的请求
            }
            axios({
                method:'GET',
                url:'http://47.98.128.191:3000/subjects/getSubjects',
                cancelToken:new axios.CancelToken((c)=>{
                    this.cancel=c
                })
            }).then(response=>{
                console.log(response);
                this.cancel=null
            })
        }
    }
}
</script>

<style>

</style>